Skip to content

fix: updating credentials alerts and management patterns#73

Merged
drduhe merged 1 commit intomainfrom
fix/update-creds-alerts
Feb 13, 2026
Merged

fix: updating credentials alerts and management patterns#73
drduhe merged 1 commit intomainfrom
fix/update-creds-alerts

Conversation

@drduhe
Copy link
Copy Markdown
Collaborator

@drduhe drduhe commented Feb 13, 2026

Issue #, if available: n/a

Summary

  • AWS region auto-detection -- Replaced the hardcoded REGION = "us-west-2" in config.ts with a resolveRegion() function that follows the standard AWS precedence chain: AWS_REGION env var → AWS_DEFAULT_REGION env var → ~/.aws/config [default] profile → us-west-2 fallback.

  • Startup config warnings -- Added a ConfigWarnings toast system that validates AWS configuration on app launch. Performs an async STS GetCallerIdentity check to catch expired/invalid credentials and alerts when the region falls back to the default. Toasts are styled with the shared glass-morphism pattern and auto-dismiss (12s for warnings, 20s for errors).

  • Fixed broken credential error handling -- s3Helper.ts and smHelper.ts had e instanceof CredsExpiredAlert in their catch blocks, but CredsExpiredAlert is a React component, not an Error class. The instanceof check itself threw TypeError: Function has non-object prototype 'undefined', turning every caught AWS error into an uncaught exception. Replaced with a shared isCredentialError() utility that detects auth failures by error name and HTTP status code.

  • Fixed S3 client stale credentials -- The S3Client in s3Helper.ts was instantiated once at module load with static credentials. After refreshing ~/.aws/credentials, the client still used the original stale creds. Changed to a credentials provider function so the SDK reads fresh credentials on every request.

  • Hardened modal error handling -- Wrapped all async data-fetching useEffect calls in ImageRequestModal, LoadDataModal, and LoadImageModal with try/catch. Fixed res !== undefined null checks (truthy for null) to res && Array.isArray(res) && res.length > 0 to prevent null.map() crashes.

  • Modernized CredsExpiredAlert -- Rewrote to use the shared ConfigWarnings.css toast classes instead of inline styles. Added slide-in/out animations, a close (X) button, disabled state during retry, and properly typed props.

  • README overhaul -- Rewrote with features overview, architecture table, usage guides, project structure, configuration reference (including region auto-detection docs), and updated resource links. Removed outdated CloudScape reference.

Files changed

File Change
src/config.ts Region auto-detection, getConfigWarnings() async validation, isCredentialError() helper
src/util/s3Helper.ts Credentials provider function, proper error handling
src/util/smHelper.ts Proper error handling (replaced broken instanceof)
src/components/alert/ConfigWarnings.tsx New startup warning toast component
src/components/alert/ConfigWarnings.css Shared toast styles + action button
src/components/alert/CredsExpiredAlert.tsx Rewritten to match shared toast pattern
src/components/modal/ImageRequestModal.tsx try/catch + null-safe array checks
src/components/modal/LoadDataModal.tsx try/catch + null-safe array checks
src/components/modal/LoadImageModal.tsx try/catch + null-safe array checks
src/App.tsx Renders <ConfigWarnings />

Checklist

Before you submit a pull request, please make sure you have the following:

  • Code changes are compact and well-structured to facilitate easy review
  • Changes are documented in the README.md and other relevant documentation pages
  • PR title and description accurately reflect the changes and are detailed enough for historical tracking
  • PR contains tests that cover all new code and the code has been manual tested
  • All new dependencies are declared (if any), and no unnecessary libraries are added
  • Performance impacts (if any) of the changes are evaluated and documented
  • Security implications of the changes (if any) are reviewed and addressed
  • I have read the Contributing Guidelines and agree to follow the Code of Conduct

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@drduhe drduhe force-pushed the fix/update-creds-alerts branch from 238e2dd to 9230f5a Compare February 13, 2026 16:11
Copy link
Copy Markdown

@devinglauner devinglauner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@drduhe drduhe merged commit 0957ce4 into main Feb 13, 2026
3 checks passed
@drduhe drduhe deleted the fix/update-creds-alerts branch February 25, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants